#include "matrix.h"


Matrix::Matrix() {}

void Matrix::setDimension(size_t rows, size_t cols) {
 	_matrix= vector<vector<double> >(rows, 
			vector<double>(cols)); 
}

double& Matrix::operator() (size_t row, size_t col) {
	return _matrix[row][col];
}

size_t Matrix::rows() {
	return _matrix.size();
}

size_t Matrix::cols() {
	return _matrix[0].size();
}

ostream& operator<<(ostream& o, Matrix& p) { 
  	o << p.rows() << " " << p.cols() << endl;   

	for(size_t i= 0; i<p.rows(); i++) { 
		for(size_t j= 0; j<p.cols(); j++) {
/*   			o << i << " " << j << " " << p(i,j) << endl;    */

               o << p(i,j) << " ";   
		}
   		o << endl;   
	} 

	return o; 
} 
istream& operator>>(istream& is, Matrix& p) { 
	size_t rows, cols;
	is >> rows;
	is >> cols;
	p.setDimension(rows, cols);
	
	for(size_t i= 0; i<rows; i++) {
		for(size_t j= 0; j<cols; j++) {
			is >> p(i,j);
		}
	}

	return is;
} 

